<?php
class Parameters{
	private $_parametersData;
	private $_dataKey;
	
	private static  $_instance;	
		
	private function __construct(){
	}
	private function __clone() {}
	
	public static function get($key = null) {
		if( ! (self::$_instance instanceof self) ) {
			self::$_instance = new self();
		}
		self::$_instance->setParametersData($_GET,$key);
		
		return self::$_instance;
	}
	
	public static function post($key = null) {
		if( ! (self::$_instance instanceof self) ) {
			self::$_instance = new self();
		}
		
		self::$_instance->setParametersData($_POST,$key);		
		
		return self::$_instance;
	}
	
	public static function request($key = null) {
		if( ! (self::$_instance instanceof self) ) {
			self::$_instance = new self();
		}		
		self::$_instance->setParametersData($_REQUEST,$key);
		return self::$_instance;
	}
	
	public function setParametersData($type,$key = null){		
		if (!empty($key)){
			self::$_instance->_parametersData = isset($type[$key])?$type[$key]:null;
		}else{
			self::$_instance->_parametersData = $type;
		}
	}
	
	public function toArray(){
		return $this->_parametersData;
	}
	
	public function vaild(){
		return !empty($this->_parametersData);
	}
	public function __get($name){
		return isset($this->_parametersData[$name])?$this->_parametersData[$name]:null;
	}
}